package collect;

import java.util.Date;
import java.util.TreeMap;
import java.util.Vector;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import bean.DataLoad;
import bean.NodeBean;
import bean.NodeTypeBean;

public class TelnetMain {
	
	public static void main(String[] args) throws Exception {
		String rootPath = args.length >0 ? args[0]:"E:/workspace/javaTelenet/bin/";
		String typeFile = rootPath + "telnet-nodetypes.xml";
		String nodeFile = rootPath + "telnet-nodes.txt";
		String outputPath = rootPath + "output/";
		
		System.out.println(new Date() + ":begin load telnet data");

		TreeMap nodeTypeBeans = DataLoad.getNodeTypeBeans(typeFile);
		Vector  nodes = DataLoad.getNodeBeans(nodeFile); 
		NodeTypeBean nodeType;
		NodeBean node;
		
		int size = nodes.size();
		System.out.println(new Date() + ":begin execute telnet task for nodes,all count: "+size);
		
		//ExecutorService executor = Executors.newFixedThreadPool(5);
		
		for (int i = 0; i < size; i++) { // 对每个节点
			node = (NodeBean) nodes.get(i);
			nodeType = ((NodeTypeBean) (nodeTypeBeans.get(node.nodeType)));
			new WorkThread(node,nodeType,outputPath).start();
			//executor.execute(new WorkThread(node,nodeType,outputPath));
		}
		/*executor.shutdown();
        while (!executor.isTerminated()) {
        }
        System.out.println("Finished all threads");*/
		
	}

}


